/*
 * rs232.h
 *
 *  Created on: 2011-5-30
 *      Author: TUZHYU
 */

#ifndef RS232_H_
#define RS232_H_

#include "./serial/cross_serial_port.h"
#include "myfu.h"
#include <time.h>

using namespace std;
class rs232
    {
public:
    rs232();
    virtual ~rs232();
    CrossPlatformSerial serialPort;
    clock_t strTime, currentTime;
    int speed, wordSize, stopBits, waitTime;
    char parity, *portName, *inputString;
    char readBuf[1024];
    int bufSize;
    int writeSize, readSize;

    int getcalcdata();
    bool jeima(char* data, int& ms);
    bool nezjeima(char* st);
    bool sdjeima(char* st);
    bool hdjeima(char* st);
    bool jdjeima(char* st);
    void hfjhautocalc();
    //    void runThread();
    void autocalccz(double&n, double&e, double&z);
    bool calchfjh(double& N, double& E, double& Z, double& oldN, double& oldE,
	    double& oldZ, double& H, double& oldH, double& HD, double& oldHD,
	    double& VD, double& oldVD, double yg = 0, double jg = 0);
    double N, E, Z, SD, VD, HD, V, H;
    int BCC;
    char L[2], P[3], O[3], TITL[5];
    char ID, m_f, d_g_m, t_qx;
    //    double x, y, gc, yg, jg, yqsengc, oldH;
private:
    bool psbcc(char *, char unsigned &bcc);
    void psdfm(double& angle);

    };

#endif /* RS232_H_ */
